//
//  WHYVisitorViewController.m
//  WHYWeibo-OC
//
//  Created by 王洪运 on 15/11/23.
//  Copyright © 2015年 王洪运. All rights reserved.
//

#import "WHYVisitorViewController.h"
#import "WHYVisitorView.h"
#import "WHYOauthViewController.h"

@interface WHYVisitorViewController ()
@property (assign, nonatomic) BOOL userLogon;



@end

@implementation WHYVisitorViewController

#pragma mark - 设置启动页面
-(void)loadView {
    self.userLogon ? [super loadView] : [self setupVisitorView];
    
    
}

#pragma mark - 监听按钮点击事件
-(void)clickRegisterBarButtonItem {
    NSLog(@"clickRegister");
}

-(void)clickLoginBarButtonItem {

    WHYOauthViewController *vc = [WHYOauthViewController new];
    UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:vc];
    
    [self presentViewController:nav animated:YES completion:nil];
}

-(void)setupVisitorView {
    self.userLogon = NO;
    self.visitorView = [WHYVisitorView new];
    self.view = self.visitorView;
    
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"注册" style:UIBarButtonItemStylePlain target:self action:@selector(clickRegisterBarButtonItem)];
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"登陆" style:UIBarButtonItemStylePlain target:self action:@selector(clickLoginBarButtonItem)];
    
    [self.visitorView visitorViewDidClickRegisterButton:^{
        [self clickRegisterBarButtonItem];
    }];
    [self.visitorView visitorViewDidClickLoginButton:^{
        [self clickLoginBarButtonItem];
    }];
    
}




@end
